package avicit.cbb.elefileupdown.rest;


import avicit.cbb.elefileupdown.service.FileUploadIntfsService;
import avicit.cbb.elefileupdown.service.api.FileUploadIntfsServiceApi;
import avicit.im.lantop.userauthset.rest.UserAuthServiceRest;
import avicit.platform6.core.rest.msg.ResponseMsg;
import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "FileUploadIntfsService", description = "FileUploadIntfs_Service")
@RequestMapping("/api/avicit/cbb/elefileupdown/rest/FileUploadIntfsServiceRest")
public class FileUploadIntfsServiceRest {


    private static final Logger LOGGER = LoggerFactory.getLogger(FileUploadIntfsServiceRest.class);


    @Autowired
    private FileUploadIntfsService fileUploadIntfsService;

    /**
     *通过数据id获取附件信息集合
     * @param map
     * @return
     */
    @PostMapping("/getAttachmentsByRecordId")
    @ApiOperation(value = "通过数据id获取附件信息集合")
    public ResponseMsg<List<Map<String, Object>>> getAttachmentsByRecordId(@ApiParam(value = "通过数据id获取附件信息集合", name = "map") @RequestBody Map<String,Object> map) {
        ResponseMsg<List<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        try {
            String dataId = (String) map.get("dataId");
            List<Map<String, Object>> attachmentsByRecordId = fileUploadIntfsService.getAttachmentsByRecordId(dataId);
            responseMsg.setResponseBody(attachmentsByRecordId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }
}
